import request from '@/utils/request'
//消息增删
export function getMessageList(page) {
  let params = Object.assign({}, { page })
  return request({
    url: 'api/back/message/messageList',
    method: 'get',
    params
  })
}

export function deleteMessage(scope) {
  let params = Object.assign({}, { msg_id: scope.row.id })
  return request({
    url: 'api/back/message/deleteMessage',
    method: 'post',
    params
  })
}

export function addMessage(params) {
  return request({
    url: 'api/back/message/createUpdateMessage',
    method: 'post',
    params
  })
}
//用户
export function getUserList(pageSize, page, search) {
  let params = Object.assign({}, { pageSize, page, search })
  return request({
    url: 'api/back/user/userList',
    method: 'get',
    params
  })
}
export function forbidden(user_id) {
  let params = Object.assign({}, { user_id })
  return request({
    url: 'api/back/user/lockUser',
    method: 'post',
    params
  })
}
//班级模块
export function getClassList(id, keyword) {
  let params = Object.assign({}, { class_id: id }, { keyword: keyword })
  return request({
    url: 'api/back/classes/classList',
    method: 'get',
    params
  })
}
export function editClass(params) {
  return request({
    url: 'api/back/classes/editClass',
    method: 'get',
    params
  })
}
export function createUpdateClass(params) {
  return request({
    url: 'api/back/classes/createUpdateClass',
    method: 'post',
    params
  })
}
export function deleteClass(id) {
  let params = Object.assign({ class_relationship_id: id })
  console.log(id)
  return request({
    url: 'api/back/classes/deleteClass',
    method: 'post',
    params
  })
}
//课程模块
export function getCourseList(pageSize, page, id, type, courseName) {
  let params = Object.assign({}, { pageSize: pageSize }, { page: page }, { course_class_id: id }, { type: type }, { course_name: courseName })
  return request({
    url: 'api/back/course/courseList',
    method: 'get',
    params
  })
}
export function soldOut(id) {
  let params = Object.assign({}, { id: id })
  return request({
    url: 'api/back/course/putAwayCourse',
    method: 'post',
    params
  })
}
export function delCourse(id) {
  let params = Object.assign({}, { id: id })
  return request({
    url: 'api/back/course/delCourse',
    method: 'post',
    params
  })
}
export function freeCourse(id) {
  let params = Object.assign({}, { id: id })
  return request({
    url: 'api/back/course/freeCourse',
    method: 'post',
    params
  })
}
export function chooseLevel(id) {

  let params = Object.assign({}, { class_id: id })
  return request({
    url: 'api/common/chooseLevel',
    method: 'get',
    params
  })
}
export function chooseChapter(id) {
  let params = Object.assign({}, { class_relationship_id: id })
  return request({
    url: 'api/common/chooseChapter',
    method: 'get',
    params
  })
}
export function chooseLang() {
  return request({
    url: 'api/common/chooseType',
    method: 'get'
  })
}
export function chooseClass() {
  return request({
    url: 'api/common/chooseClass',
    method: 'get',
  })
}
export function addCourseList(params) {
  return request({
    url: 'api/back/course/addCourse',
    method: 'post',
    params
  })
}
export function getCourse(id) {
  let params = Object.assign({}, { id })
  return request({
    url: 'api/back/course/getCourse',
    method: 'get',
    params
  })
}
// 规则设置
export function setRules(content) {
  let params = Object.assign({}, { rule_content: content })
  return request({
    url: 'api/back/setRule',
    method: 'post',
    params
  })
}
//奖励设置
export function setReword(content) {
  let params = Object.assign({}, { reward_content: content })
  return request({
    url: 'api/back/setReword',
    method: 'post',
    params
  })
}
// 读书模块
export function getBookList(page, is_putaway, keyword) {
  let params = Object.assign({}, { page, is_putaway, keyword })
  return request({
    url: 'api/back/book/bookList',
    method: 'get',
    params
  })
}
export function isPutaway(book_id, my_type, sort) {
  let params = Object.assign({}, { book_id, my_type, sort })
  return request({
    url: 'api/back/book/bookSortPutaway',
    method: 'post',
    params
  })
}
export function deleteBook(book_id) {
  let params = Object.assign({}, { book_id })
  return request({
    url: 'api/back/book/deleteBook',
    method: 'post',
    params
  })
}
export function chooseBookAge() {
  return request({
    url: 'api/common/chooseBookAge',
    method: 'get',
  })
}
export function chooseBookType() {
  return request({
    url: 'api/common/chooseBookType',
    method: 'get'
  })
}
export function createUpdateCourse(params) {
  return request({
    url: 'api/back/book/createUpdateBook',
    method: 'post',
    params
  })
}
export function readingDiaryList(page, book_name, book_type_id) {
  let params = Object.assign({}, { page, book_name, book_type_id })
  return request({
    url: 'api/back/book/readingDiaryList',
    method: 'get',
    params
  })
}
export function getAccountList(page, is_forbidden, keyword) {
  let params = Object.assign({}, { page, is_forbidden, keyword })
  return request({
    url: 'api/back/users/accountList',
    method: 'get',
    params
  })
}
export function isForbidden(admin_id, type) {
  let params = Object.assign({}, { admin_id, type })
  return request({
    url: 'api/back/users/isForbidden',
    method: 'post',
    params
  })
}
export function createUpdateAccount(params) {
  return request({
    url: 'api/back/users/createUpdateAccount',
    method: 'post',
    params
  })
}
//权限管理
export function getModules() {
  return request({
    url: 'api/back/module/getModules',
    method: 'get'
  })
}
export function getUserPermission() {
  return request({
    url: 'api/back/module/getUserPermission',
    method: 'get'
  })
}
//订单管理
export function orderStatistics() {
  return request({
    url: 'api/back/order/orderStatistics',
    method: 'get'
  })
}
export function getOrderList(page, keyword, flag, order_status, order_type) {
  let params = Object.assign({}, { page, keyword, flag, order_status, order_type })
  return request({
    url: '/api/back/order/orderList',
    method: 'get',
    params
  })
}
export function exportOrder(page, keyword, flag, order_status, order_type) {
  let params = Object.assign({}, { page, keyword, flag, order_status, order_type })
  return request({
    url: '/api/back/order/orderList',
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json; application/octet-stream'
    },
    params
  })
}
export function deleteOrder(order_id) {
  let params = Object.assign({}, {order_id})
  return request({
    url: 'api/back/order/deleteOrder',
    method: 'post',
    params
  })
}
export function getOrderInfo(order_id) {
  let params = Object.assign({}, {order_id})
  return request({
    url: 'api/back/order/orderInfo',
    method: 'get',
    params
  })
}